package com.example.demo;

import com.example.demo.filters.inbound.Debug;
import com.example.demo.filters.inbound.DebugRequest;
import com.example.demo.filters.inbound.InAFilter;
import com.example.demo.filters.inbound.InBFilter;
import com.example.demo.filters.inbound.Routes;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.netflix.zuul.BasicFilterUsageNotifier;
import com.netflix.zuul.DynamicCodeCompiler;
import com.netflix.zuul.FilterFactory;
import com.netflix.zuul.FilterUsageNotifier;
import com.netflix.zuul.filters.ZuulFilter;
import com.netflix.zuul.groovy.GroovyCompiler;
import com.netflix.zuul.guice.GuiceFilterFactory;

import com.example.demo.filters.endpoint.NotFoundEndpoint;
import com.example.demo.filters.outbound.OutAFilter;
import com.example.demo.filters.outbound.OutBFilter;
import com.example.demo.filters.outbound.ZuulResponseFilter;

/**
 * @author sleepforests
 * Created on 2019-06-27
 */
public class ZuulClasspathFiltersModule extends AbstractModule {
    @Override
    protected void configure() {
        bind(DynamicCodeCompiler.class).to(GroovyCompiler.class);
        bind(FilterFactory.class).to(GuiceFilterFactory.class);

        bind(FilterUsageNotifier.class).to(BasicFilterUsageNotifier.class);

        Multibinder<ZuulFilter> filterMultibinder = Multibinder.newSetBinder(binder(), ZuulFilter.class);
        filterMultibinder.addBinding().to(Routes.class);
        filterMultibinder.addBinding().to(NotFoundEndpoint.class);
//        filterMultibinder.addBinding().to(ZuulResponseFilter.class);
//        filterMultibinder.addBinding().to(Debug.class);
//        filterMultibinder.addBinding().to(DebugRequest.class);

//        filterMultibinder.addBinding().to(InAFilter.class);
//        filterMultibinder.addBinding().to(InBFilter.class);
//        filterMultibinder.addBinding().to(OutAFilter.class);
//        filterMultibinder.addBinding().to(OutBFilter.class);



//        filterMultibinder.addBinding().toInstance(
//                new StripPrefixFilter(Arrays.asList("/passthrough/.*")));
    }
}
